﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class LoginPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        { }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (txtPassword.Text == txtPasswordRetype.Text)
        {
            string sql = @"
INSERT INTO [Login]
           ([Name]
           ,[Email]
           ,[Mobile]
            ,Masking
           ,[Password]
            ,RemainingSMS
           ,[AddedDate])
     VALUES
           ('" + txtName.Text + @"'
           ,'" + txtEmail.Text + @"'
           ,'" + txtMobile.Text + @"'
           ,'" + txtDefaultMasking.Text + @"'
           ,'" + txtPassword.Text + @"'
,0
           ,GETDATE());
Declare @LoginID int
set @LoginID=SCOPE_IDENTITY();
INSERT INTO [Purchase]
           ([LoginID]
           ,[PurchaseDate]
           ,[Amount]
           ,[PurchaseNo]
           ,[Remaining])
     VALUES
           (@LoginID
           ,GETDATE()
           ,0
           ,0
           ,0);
INSERT INTO [Group]
           ([GroupName]
           ,[LoginID]
           ,[AddedDate]
           ,[StatusID])
     VALUES
           ('My Contacts'
           ,@LoginID
           ,Getdate()
           ,1);
Declare @GroupID int
set @GroupID=SCOPE_IDENTITY();

INSERT INTO [Contact]
           ([Name]
           ,[ShortName]
           ,[MobileNo]
           ,[GroupID])
     VALUES
           ('"+txtName.Text+@"'
           ,'"+txtDefaultMasking.Text+@"'
           ,'"+txtMobile.Text+ @"'
           ,@GroupID);
";
            DatabaseManager.ExecSQL(sql);
            Response.Redirect("Loginpage.aspx");

        }
    }
}